asynx.impl.array = {
	A: function(obj) {
		var arr = [];
		for(var i = 0; i < obj.length; i++) arr.push(obj[i]);
		return arr;
	},
	
	merge: function(first, second) {
		for (var i = 0; second[i]; i++) {
			first.push(second[i]);
		}
		return first;
	},
	
	diff: function(a1, a2) {
		var ret = [];
		for(var i = 0; i < a1.length; i++) {
			if(!this.canInclude(a2, a1[i])) {
				ret.push(a1[i]);
			}
		}
		return ret;
	},
	
	canInclude: function(array, value) {
		for(var i = 0; i < array.length; i++) {
			if(array[i] == value)
				return true;
		}
		return false;
	},
	
	unique: function(array) {
		for(var i = 0; i < array.length; i++) {
			for(var x = i + 1; x < array.length; x++) {
				if(array[i] == array[x]) {
					for(var z = x; z < array.length - 1; z++)
						array[z] = array[z + 1];
	
					array.length--;
					x--;
				}
			}
		}
		return array;
	},
	
	each: function(array, fn) {
		var scope = arguments[2];
		if (!array[0]) array = [array];
		for (var x=0; x < array.length; x++) {
			if (asynx.isUndef(array[x])) continue;
			fn.call(scope?scope:array[x], array[x], x);
		}
	},
	
	forEach: function(obj, fn) {
		var scope = arguments[2];
		for (i in obj) {
			if (typeof obj[i] !== "function") {
				fn.call(scope?scope:obj, i, obj[i]);
			}
		}
	},
	
	isInArray: function(el, array) {
		for (var i = 0; i < array.length; i++) {
			if (el == array[i]) return true;			
		}
		return false;
	},
	
	arrayTrim: function(a) {
		var results = [];
		asynx.each(a, function(el) {
			results.push(asynx.trim(el));
		});
		return results;
	}
};

asynx.extend(asynx, asynx.impl.array);
delete asynx.impl.array;
